package com.web.music.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;

@Entity
public class Person implements PersistentObject {
	
	@Id
	private Long id;
	
	private String name;
	
	private String surname;
	
	@OneToOne(mappedBy="person")
	private Singer singerInfo;
	
	@ManyToMany(mappedBy="members")
	private List<MusicBand> musicBands;
	
	public Person() {
		super();
	}

	public Person(Long id, String name, String surname) {
		super();
		this.id = id;
		this.name = name;
		this.surname = surname;
	}

	public String getName(){
		return name;
	}
	
	public void setName(String name ){
		this.name = name;
	}
	
	public String getSurname(){
		return surname;
	}
	
	public void setSurname(String surname ){
		this.surname = surname;
	}
	
	public Singer getSingerInfo() {
		return singerInfo;
	}
	
	public void setSingerInfo(Singer singerInfo) {
		this.singerInfo = singerInfo;
	}
	
	public List<MusicBand> getMusicBands() {
		return musicBands;
	}
	
	public void setMusicBands(List<MusicBand> musicBands) {
		this.musicBands = musicBands;
	}
	
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public String toString(){
		return id + " " + name + " " + surname;
	}

	@Override
	public boolean equals(Object obj) {
		boolean result = true;
		if (obj instanceof Person) {
		
			result = this.id.equals(((Person) obj).getId())
					&& this.name.equals(((Person) obj).getName())
					&& this.surname.equals(((Person) obj).getSurname());
			return result;
		}
	return false;
	}
}
